// external.js
export default {
	calculatedData(data) {
		console.log('处理数据---JS', data);
		// 测线条数
		let numberOfCeXian = data.underwaterPenetrationConfig.cexianList.length //数组长度
		// 数据对象
		let gatherFlowTrucks = {}
		gatherFlowTrucks.ssId = data.ssId //测站/灌溉站id
		gatherFlowTrucks.sfsId = data.sfsId //测段Id
		gatherFlowTrucks.fmpId = data.fmpId //计量点ID
		gatherFlowTrucks.id = data.id //断面参数ID
		gatherFlowTrucks.type = data.type //type为0是测段；type为1是计量点
		gatherFlowTrucks.stationType = data.stationType //站类型：0,测站；1,灌溉站
		gatherFlowTrucks.name = data.ceduanName //测段名称----------------
		gatherFlowTrucks.cexiantiaoshu = data.cexiantiaoshu //测线条数
		gatherFlowTrucks.qudikuandu = data.qudikuandu //渠底宽度
		gatherFlowTrucks.cezhanID = data.cezhanID //ID
		gatherFlowTrucks.k = data.k //k
		gatherFlowTrucks.n = data.n //n
		
		gatherFlowTrucks.duopuleche = {
			name: '多普勒车', //名称
			kL: data.raisedShore, //左岸系数
			kR: data.endingShore, //右岸系数
			lSA: data.startingEdge, //左坡脚
			rSA: data.endEdge, //右坡角
			cexiantiaoshu: data.cexiantiaoshu, //测线条数
			cexianList: [], //测线
			qudikuandu: data.qudikuandu, //渠底宽度
			surfaceVelocityCoefficient: data.surfaceVelocityCoefficient //多普勒系数
		}
		gatherFlowTrucks.celiugan = {
			name: '测流杆', //名称
			kL: data.raisedShore, //左岸系数
			kR: data.endingShore, //右岸系数
			lSA: data.startingEdge, //左坡脚
			rSA: data.endEdge, //右坡角
			cexiantiaoshu: data.cexiantiaoshu, //测线条数
			cexianList: [], //测线
			qudikuandu: data.qudikuandu, //渠底宽度
			surfaceVelocityCoefficient: data.surfaceVelocityCoefficient, //多普勒系数
		}

		gatherFlowTrucks.guidaoche = {
			name: '轨道车', //名称
			kL: data.raisedShore, //左岸系数
			kR: data.endingShore, //右岸系数
			lSA: data.startingEdge, //左坡脚
			rSA: data.endEdge, //右坡角
			cexiantiaoshu: data.cexiantiaoshu, //测线条数
			cexianList: [], //测线
			qudikuandu: data.qudikuandu, //渠底宽度
			surfaceVelocityCoefficient: data.surfaceVelocityCoefficient, //多普勒系数
		}

		gatherFlowTrucks.suodaoche = {
			name: '索道车', //名称
			kL: data.raisedShore, //左岸系数
			kR: data.endingShore, //右岸系数
			lSA: data.startingEdge, //左坡脚
			rSA: data.endEdge, //右坡角
			cexiantiaoshu: data.cexiantiaoshu, //测线条数
			cexianList: [], //测线
			qudikuandu: data.qudikuandu, //渠底宽度
			surfaceVelocityCoefficient: data.surfaceVelocityCoefficient, //多普勒系数
		}

		for (var i = 0; i < data.cexiantiaoshu; i++) {
			// 测流杆
			let clgobj = {}
			clgobj.id = i + 1
			clgobj.cR = data.underwaterPenetrationConfig.cexianList[i].cR
			clgobj.bC = data.underwaterPenetrationConfig.cexianList[i].celiugan
			clgobj.zJ = data.horizontalWalkConfig.cexianList[i].celiugan
			gatherFlowTrucks.celiugan.cexianList.push(clgobj)


			// 轨道车
			let gdcobj = {}
			gdcobj.id = i + 1
			gdcobj.cR = data.underwaterPenetrationConfig.cexianList[i].cR
			gdcobj.bC = data.underwaterPenetrationConfig.cexianList[i].guidaoche
			gdcobj.zJ = data.horizontalWalkConfig.cexianList[i].guidaoche
			gatherFlowTrucks.guidaoche.cexianList.push(gdcobj)


			// 索道车
			let sdcobj = {}
			sdcobj.id = i + 1
			sdcobj.cR = data.underwaterPenetrationConfig.cexianList[i].cR
			sdcobj.bC = data.underwaterPenetrationConfig.cexianList[i].suodaoche
			sdcobj.zJ = data.horizontalWalkConfig.cexianList[i].suodaoche
			gatherFlowTrucks.suodaoche.cexianList.push(sdcobj)


			// 多普勒
			let dplobj = {}
			dplobj.id = i + 1
			dplobj.cR = data.underwaterPenetrationConfig.cexianList[i].cR
			dplobj.bC = data.underwaterPenetrationConfig.cexianList[i].duopuleche
			dplobj.zJ = data.horizontalWalkConfig.cexianList[i].duopuleche
			gatherFlowTrucks.duopuleche.cexianList.push(dplobj)


		}

		console.log('-------', gatherFlowTrucks);
		// 循环铅鱼底
		for (var i = 0; i < data.underwaterPenetrationConfig.datumMarkList.length; i++) {
			if(data.underwaterPenetrationConfig.datumMarkList[i].type == '测流杆'){
				gatherFlowTrucks.celiugan.liusuyiHeight = data.underwaterPenetrationConfig.datumMarkList[i].liusuyiHeight
				gatherFlowTrucks.celiugan.lsydqydData = data.underwaterPenetrationConfig.datumMarkList[i].lsydqydData
				gatherFlowTrucks.celiugan.datumMark = data.underwaterPenetrationConfig.datumMarkList[i].datumMark
			}
			if(data.underwaterPenetrationConfig.datumMarkList[i].type == '轨道车'){
				gatherFlowTrucks.guidaoche.liusuyiHeight = data.underwaterPenetrationConfig.datumMarkList[i].liusuyiHeight
				gatherFlowTrucks.guidaoche.lsydqydData = data.underwaterPenetrationConfig.datumMarkList[i].lsydqydData
				gatherFlowTrucks.guidaoche.datumMark = data.underwaterPenetrationConfig.datumMarkList[i].datumMark
			}
			if(data.underwaterPenetrationConfig.datumMarkList[i].type == '索道车'){
				gatherFlowTrucks.suodaoche.liusuyiHeight = data.underwaterPenetrationConfig.datumMarkList[i].liusuyiHeight
				gatherFlowTrucks.suodaoche.lsydqydData = data.underwaterPenetrationConfig.datumMarkList[i].lsydqydData
				gatherFlowTrucks.suodaoche.datumMark = data.underwaterPenetrationConfig.datumMarkList[i].datumMark
			}
			if(data.underwaterPenetrationConfig.datumMarkList[i].type == '多普勒车'){
				gatherFlowTrucks.duopuleche.liusuyiHeight = data.underwaterPenetrationConfig.datumMarkList[i].liusuyiHeight
				gatherFlowTrucks.duopuleche.lsydqydData = data.underwaterPenetrationConfig.datumMarkList[i].lsydqydData
				gatherFlowTrucks.duopuleche.datumMark = data.underwaterPenetrationConfig.datumMarkList[i].datumMark
			}
			
			console.log('iii', i);
		}


		// if (name == '单轨测流车') {

		// 	let cexianList = []
		// 	for (let i = 0; i < numberOfCeXian; i++) {
		// 		let obj = {}
		// 		obj.id = i + 1
		// 		obj.cR = data.underwaterPenetrationConfig.cexianList[i].cR
		// 		obj.bC = data.underwaterPenetrationConfig.cexianList[i].duopuleche
		// 		obj.zJ = data.horizontalWalkConfig.cexianList[i].duopuleche
		// 		cexianList.push(obj)

		// 	}
		// 	obj.cexianList = cexianList //测线
		// }
		console.log('处理完成',gatherFlowTrucks);
		return gatherFlowTrucks
	},
};